package com.code.leetcode.offer;

import com.code.leetcode.utils.ListNode;

import java.util.List;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/8/3 21:23
 */
public class The52 {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode node1 = headA;
        ListNode node2 = headB;
        while (node1 != node2) {
            node1 = node1 == null ? headB : node1.next;
            node2 = node2 == null ? headA : node2.next;
        }
        return node1;
    }
}
